<?php
namespace app\modules\info\models;
use Yii;
class authcheck{
	public function openCurlPost($url=AUTHURL){
		$ch=curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch,CURLOPT_HEADER,0);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$info= curl_exec($ch);
		curl_close($ch);
		return $info;
	}
	/**
	 * 注册使用授权码&获取本系统是否在有效期
	 * @param $code不为空是注册，为空是查询
	 */
	function authorityCheck($code="",$sys=32,$ver="2.0.1",$path="aa"){
		if($code != ""){
            $url = AUTHURL."?sys=".$sys."&ver=".$ver."&path=".$path."&code=".$code;
        }else{
            $url = AUTHURL."?sys=".$sys."&ver=".$ver."&path=".$path;
        }
        $json=$this->openCurlPost($url);
        $json = iconv('gb2312','utf-8', $json);
        if($json){
        	$return=json_decode($json,true);
        }else{
        	$return['state']="false";
        	$return['message']="请求本地服务失败";
        }
        return $return;
	}
}
